package cn.ylhx.venue.cityAdd.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.ylhx.venue.cityAdd.entity.City;
import cn.ylhx.venue.cityAdd.service.CityService;
import cn.ylhx.venue.common.web.JsonResult;

@Controller
@RequestMapping("/city")
public class CityController{
	@Resource
	private CityService cityService;
	
	@RequestMapping("/editUI")
	public String editUI(){
		return "city/city_edit";
	}
	//加载城市信息的treetable
	@RequestMapping("/listUI")
	@RequiresPermissions("site:city:view")
	public String listUI(){
		return "city/city_list";
	}
    @RequestMapping("/doFindObjects")
	@ResponseBody
	@RequiresPermissions("site:city:view")
	public JsonResult doFindObjects(){
		List<Map<String,Object>> list=
				cityService.findObjects();
		System.out.println("list=="+list);
		return new JsonResult(list);
	}
    //加载城市树的节点
    @RequestMapping("/doFindTreeNodes")
	@ResponseBody
    public JsonResult doFindTreeNodes(){
    	List<Map<String,Object>> list=
    			cityService.findTreeNodes();
    	return new JsonResult(list);
    }
    @RequestMapping("/doSaveObject")
   	@ResponseBody
    public JsonResult doSaveObject(City city){
    	cityService.saveObject(city);
    	return new JsonResult();
    }
    @RequestMapping("/doFindObjectById")
    @ResponseBody
    public JsonResult doFindObjectById(Integer id){
    	Map<String,Object> map=
    			cityService.findObjectById(id);
    	return new JsonResult(map);
    }
    
    @RequestMapping("/doUpdateObject")
    @ResponseBody
    public JsonResult doUpdateObject(City city){
    	cityService.updateObject(city);
    	return new JsonResult();
    }
    @RequestMapping("/doDeleteObject")
    @ResponseBody
    public JsonResult doDeleteObject(Integer id){
    	cityService.deleteObject(id);
    	return new JsonResult();
    }
}










